package EA;
import EA.recording.FitEvalCountListener;

public class NumericalFitness extends Fitness
{

  /** Create a new NumericalFitness. */
  public NumericalFitness()
    {
      super();
      initialize(null, null);
    }

  /** Create a new NumericalFitness. The container object can be used
      to pass a reference to an object used by the function. 
      (Especially used in dynamic problems.) The method will call 
      initialize(container, null)
      which can be overridden by anonymous subclasses.
      
      @param container A container for this fitness function.
  */
  public NumericalFitness(Object container)
    {
      super();
      initialize(container, null);
    }


  /** Create a new NumericalFitness. The two container objects can be used
      to pass a reference to a container object used by the function. 
      (Especially used in dynamic problems.) The method will call initialize
      which can be overridden by anonymous subclasses.
      
      @param container1 A container for this fitness function.
      @param container2 A container for this fitness function.
  */
  public NumericalFitness(Object container1, Object container2)
    {
      super();
      initialize(container1, container2);
    }

  /** Initialize the function. This is called from the constructors. null
      is passed twice from the constructor with no arguments. */
  public void initialize(Object container1, Object container2)
    {
    }

  /** 
      Calculate the fitness in a given point in the searchspace. The
      reason why this is a final method is because you have to use
      override Fitness_calcFitness_inner(double[] realpos) instead.  
  */
  public final double calcFitness(double[] realpos)
    {
      if (countlistener!=null && fitevalsamplerate>0) {
	currentevals++;
	if (currentevals%fitevalsamplerate ==0) {
	  countlistener.fitnessEvaluationsCounted(currentevals);
	}
      }
      return Fitness_calcFitness_inner(realpos);
    }

  public double Fitness_calcFitness_inner(double[] realpos)
    {
      return 0;
    }

}
